Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 7, 2026

Code style warnings from .editorconfig were visible in the IDE but not enforced when building with /warnaserror, allowing violations to be introduced.

Changes

Build configuration:

  • Added AnalysisLevelStyle=latest to enable IDE code style analyzers during build
  • Enabled GenerateDocumentationFile to activate IDE0005 (unused usings) detection
  • Suppressed documentation warnings (CS1591, CS1573, CS1584, CS1658) - only style enforcement needed
  • Added test/Directory.Build.props to relax IDE0051, IDE0052, IDE0059 for test code

Code fixes:

  • Removed unnecessary using directives (IDE0005)
  • Fixed modifier ordering: override asyncasync override (IDE0036)
  • Removed unnecessary public on interface members (IDE0040)
  • Removed unused private fields and parameters (IDE0052, IDE0060)
  • Fixed formatting violations (IDE0055)

False positive suppressions:
Two using directives incorrectly flagged by IDE0005 required pragmas - extension methods not recognized by analyzer:

#pragma warning disable IDE0005 // False positive: GetService<T>() requires this
using Microsoft.Extensions.DependencyInjection;
#pragma warning restore IDE0005

Result

Code style violations now fail builds with /warnaserror:

// This now fails the build:
var number = 42;  // error IDE0008: Use explicit type instead of 'var'
Original prompt

This section details on the original issue you should resolve

<issue_title>Enforce code style rules in build</issue_title>
<issue_description>Describe the bug
Code style warnings show up in the IDE, but they are not enforced when /warnaserror is used for a build, so copilot agents are introducing new code style issues.

To Reproduce
Steps to reproduce the behavior:

  1. Introduce a code style issue (e.g. use 'var' instead of an explicit type)
  2. Build the project with /warnaserror

Expected behavior
Build should fail because there is a code style warning from the build

Additional context
As part of this work, fix any code style issues that are causing the build to fail.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Enforce code style rules in build process Enforce code style rules during build Jan 7, 2026
Copilot AI requested a review from jodavis January 7, 2026 19:23
@jodavis jodavis marked this pull request as ready for review January 7, 2026 22:49
@github-actions
Copy link

github-actions bot commented Jan 7, 2026

Test Results

306 tests  ±0   304 ✅ ±0   49s ⏱️ -4s
  3 suites ±0     2 💤 ±0 
  3 files   ±0     0 ❌ ±0 

Results for commit 9dc85de. ± Comparison against base commit 30c1639.

This pull request removes 3 and adds 2 tests. Note that renamed tests count towards both.
,False)
AdaptiveRemote.Services.ProgrammaticSettings.PersistSettingsTests ‑ PersistSettings_Set_ValidatesKeyName (Hello
AdaptiveRemote.Services.ProgrammaticSettings.PersistSettingsTests ‑ PersistSettings_Set_ValidatesValue (Invalid
AdaptiveRemote.Services.ProgrammaticSettings.PersistSettingsTests ‑ PersistSettings_Set_ValidatesKeyName (Hello
,False)
AdaptiveRemote.Services.ProgrammaticSettings.PersistSettingsTests ‑ PersistSettings_Set_ValidatesValue (Invalid
,False)

♻️ This comment has been updated with latest results.

Copilot AI and others added 4 commits January 9, 2026 18:02
- Added AnalysisLevelStyle=latest to enable code style analysis
- Enabled GenerateDocumentationFile to enable IDE0005 (unused usings) detection
- Suppressed documentation warnings (CS1591, CS1573, CS1584, CS1658)
- Fixed existing code style violations:
  - Fixed formatting issues (IDE0055)
  - Fixed modifier order (IDE0036)
  - Removed unnecessary accessibility modifiers (IDE0040)
  - Removed unused private members (IDE0052, IDE0060)
  - Removed unnecessary using directives (IDE0005)

Code style warnings now properly fail the build when /warnaserror is used.

Co-authored-by: jodavis <6740581+jodavis@users.noreply.github.com>
- Added test/Directory.Build.props to relax some code style rules for tests
- Fixed unnecessary using directives with pragma suppression
- Fixed formatting issues in test files
- Removed commented-out code in TaskAssert.cs

All code now passes build with /warnaserror enabled.

Co-authored-by: jodavis <6740581+jodavis@users.noreply.github.com>
Updated pragma comments to be more specific about why the IDE0005
warning is a false positive and which using directives are affected.

Co-authored-by: jodavis <6740581+jodavis@users.noreply.github.com>
@jodavis jodavis force-pushed the copilot/enforce-code-style-rules branch from 6a5a0fc to 1b49c9e Compare January 10, 2026 02:20
@jodavis jodavis merged commit f3cbbfc into main Jan 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enforce code style rules in build

3 participants